package com.supeng.PMdepot.activity.bak;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.supeng.PMdepot.R;
import com.supeng.PMdepot.base.BaseActivity;
import com.supeng.PMdepot.util.actionbar.LightStatusBarUtils;
import com.supeng.PMdepot.util.actionbar.ToolbarUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 打电话
 * Created by Supeng on 2018/10/12.
 */

public class CallPhoneActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.title_bar)
    RelativeLayout titleBar;
    @BindView(R.id.call_btn)
    Button callBtn;
    @BindView(R.id.root_layout)
    LinearLayout rootLayout;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_phone)
    TextView tvPhone;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //标题栏颜色
        ToolbarUtil.setColorNoTranslucent(this, getResources().getColor(R.color.blueColorAppKey));
        //深色主题 true字颜色为深色 false 为白色标题字
        LightStatusBarUtils.setLightStatusBar(this, false);
        setContentView(R.layout.activity_call_phone);
        unbinder = ButterKnife.bind(this);
        tvName.setText(getIntent().getStringExtra("name"));
        tvPhone.setText(getIntent().getStringExtra("phone"));

        callBtn.setOnClickListener(this);
        findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.call_btn:
                callPhone(tvPhone.getText().toString());
                break;
        }
    }

    /**
     * 拨打电话（直接拨打电话）
     *
     * @param phoneNum 电话号码
     */
    public void callPhone(String phoneNum) {
        Intent intent = new Intent(Intent.ACTION_CALL);
        Uri data = Uri.parse("tel:" + phoneNum);
        intent.setData(data);
        startActivity(intent);
    }

}
